package com.itheima.day08.myTreeSet.test2$.domain;

public class Student implements Comparable<Student> {
    private String id;
    private String name;

    public Student() {
    }

    public Student(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student student) {
        String id1 = this.id;
        String substring1 = id1.substring(7, id1.length());
        int i1 = Integer.parseInt(substring1);

        String id2 = student.id;
        String substring2 = id2.substring(7, id2.length());
        int i2 = Integer.parseInt(substring2);

        int result = i1 - i2;

        return result;
    }
}
